import sys

objects = ['Audio.cpp', 'DSP.cpp', 'DTMF.cpp', 'Filter.cpp', 'Generate.cpp', 'RMS.cpp', 'VAD.cpp', 'Gain.cpp']

env = Environment()
if 'win' in sys.platform:
    SDK = 'C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0\\'
    
    # Include
    env.Append(CPPPATH = SDK + 'Include;')
    env.Append(CPPPATH = SDK + 'VC\\INCLUDE;')
    env.Append(CPPPATH = '.\\portaudio;')
    
    # Library Path
    env.Append(LIBPATH = SDK + 'Lib;')
    env.Append(LIBPATH = SDK + 'VC\\LIB;')

    # Libraries
    env.Append(LIBS = 'portaudio\\portaudio;')
    
    # Compiler Flags
    env.Append(CCFLAGS ='/TP /GR /EHsc /DWINDOWS')
    
elif 'linux' in sys.platform:
    # Include
    env.Append(CPPPATH = '/usr/include:')
    env.Append(CPPPATH = './portaudio:')
    env.Append(CPPPATH = '.:')
    
    # Library Path
    env.Append(LIBPATH = '/usr/lib:')
    env.Append(LIBPATH = './portaudio:')

    # Libraries
    env.Append(LIBS = 'portaudio:')
    env.Append(LIBS = 'pthread:')

    # Compiler Flags
    env.Append(CCFLAGS ='-Wall -DUNIX')
    
    # Debug option
    debug = ARGUMENTS.get ('debug', 0)
    if int(debug):
       env.Append(CCFLAGS = '-g')

    # Portaudio
    SConscript(['portaudio/SConstruct'])

# Test applications should be named: test/Test_name.cpp
def Test(name):
    env.Program('test/'+name, source = objects + ['test/Test_'+name+'.cpp'])

Test('DTMF')
Test('RMS')
Test('VAD')
Test('Gain')
